sources = [
    'allocation_state.cc',
    'allocator.cc',
    'alloc_engine.cc',
    'alloc_engine_log.cc',
    'alloc_engine_messages.cc',
    'legal_log_mgr_factory.cc',
    'legal_log_mgr.cc',
    'cb_ctl_dhcp4.cc',
    'cb_ctl_dhcp6.cc',
    'cfgmgr.cc',
    'cfg_4o6.cc',
    'cfg_consistency.cc',
    'cfg_db_access.cc',
    'cfg_duid.cc',
    'cfg_expiration.cc',
    'cfg_globals.cc',
    'cfg_hosts.cc',
    'cfg_hosts_util.cc',
    'cfg_host_operations.cc',
    'cfg_iface.cc',
    'cfg_mac_source.cc',
    'cfg_multi_threading.cc',
    'cfg_option.cc',
    'cfg_option_def.cc',
    'cfg_rsoo.cc',
    'cfg_shared_networks.cc',
    'cfg_subnets4.cc',
    'cfg_subnets6.cc',
    'client_class_def.cc',
    'config_backend_dhcp4_mgr.cc',
    'config_backend_dhcp6_mgr.cc',
    'config_backend_pool_dhcp4.cc',
    'config_backend_pool_dhcp6.cc',
    'csv_lease_file4.cc',
    'csv_lease_file6.cc',
    'd2_client_cfg.cc',
    'd2_client_mgr.cc',
    'ddns_params.cc',
    'dhcp4o6_ipc.cc',
    'dhcpsrv_log.cc',
    'dhcpsrv_messages.cc',
    'flq_allocation_state.cc',
    'flq_allocator.cc',
    'host.cc',
    'hosts_log.cc',
    'hosts_messages.cc',
    'host_data_source_factory.cc',
    'host_mgr.cc',
    'ip_range.cc',
    'ip_range_permutation.cc',
    'iterative_allocation_state.cc',
    'iterative_allocator.cc',
    'lease.cc',
    'lease_mgr.cc',
    'lease_mgr_factory.cc',
    'legal_log_db_log.cc',
    'memfile_lease_limits.cc',
    'memfile_lease_mgr.cc',
    'ncr_generator.cc',
    'network.cc',
    'network_state.cc',
    'parsers/base_network_parser.cc',
    'parsers/client_class_def_parser.cc',
    'parsers/dhcp_parsers.cc',
    'parsers/dhcp_queue_control_parser.cc',
    'parsers/duid_config_parser.cc',
    'parsers/expiration_config_parser.cc',
    'parsers/host_reservation_parser.cc',
    'parsers/ifaces_config_parser.cc',
    'parsers/multi_threading_config_parser.cc',
    'parsers/option_data_parser.cc',
    'parsers/sanity_checks_parser.cc',
    'parsers/shared_network_parser.cc',
    'parsers/simple_parser4.cc',
    'parsers/simple_parser6.cc',
    'pool.cc',
    'random_allocation_state.cc',
    'random_allocator.cc',
    'resource_handler.cc',
    'sanity_checker.cc',
    'shared_network.cc',
    'srv_config.cc',
    'subnet.cc',
    'timer_mgr.cc',
    'tracking_lease_mgr.cc',
]
if FUZZ_OPT.enabled()
    sources += ['fuzz_log.cc', 'fuzz_messages.cc', 'packet_fuzzer.cc']
endif
kea_dhcpsrv_lib = shared_library(
    'kea-dhcpsrv',
    sources,
    cpp_args: [
        f'-DDHCP_DATA_DIR="@SHAREDSTATEDIR_INSTALLED@"',
        f'-DKEA_LFC_EXECUTABLE="@KEA_LFC_INSTALLED@"',
        f'-DLEGAL_LOG_DIR="@LOGDIR_INSTALLED@"',
    ],
    dependencies: [CRYPTO_DEP],
    include_directories: [include_directories('.')] + INCLUDES,
    install: true,
    install_dir: LIBDIR,
    install_rpath: INSTALL_RPATH,
    build_rpath: BUILD_RPATH,
    link_with: LIBS_BUILT_SO_FAR,
    version: '144.0.0',
)
LIBS_BUILT_SO_FAR = [kea_dhcpsrv_lib] + LIBS_BUILT_SO_FAR
subdir('testutils')
subdir('tests')
kea_dhcpsrv_headers = [
    'alloc_engine.h',
    'alloc_engine_log.h',
    'alloc_engine_messages.h',
    'allocation_state.h',
    'allocator.h',
    'legal_log_mgr_factory.h',
    'legal_log_mgr.h',
    'base_host_data_source.h',
    'cache_host_data_source.h',
    'callout_handle_store.h',
    'cb_ctl_dhcp.h',
    'cb_ctl_dhcp4.h',
    'cb_ctl_dhcp6.h',
    'cfg_4o6.h',
    'cfg_consistency.h',
    'cfg_db_access.h',
    'cfg_duid.h',
    'cfg_expiration.h',
    'cfg_globals.h',
    'cfg_host_operations.h',
    'cfg_hosts.h',
    'cfg_hosts_util.h',
    'cfg_iface.h',
    'cfg_mac_source.h',
    'cfg_multi_threading.h',
    'cfg_option.h',
    'cfg_option_def.h',
    'cfg_rsoo.h',
    'cfg_shared_networks.h',
    'cfg_subnets4.h',
    'cfg_subnets6.h',
    'cfgmgr.h',
    'client_class_def.h',
    'config_backend_dhcp4.h',
    'config_backend_dhcp4_mgr.h',
    'config_backend_dhcp6.h',
    'config_backend_dhcp6_mgr.h',
    'config_backend_pool_dhcp4.h',
    'config_backend_pool_dhcp6.h',
    'csv_lease_file4.h',
    'csv_lease_file6.h',
    'd2_client_cfg.h',
    'd2_client_mgr.h',
    'db_type.h',
    'ddns_params.h',
    'dhcp4o6_ipc.h',
    'dhcpsrv_exceptions.h',
    'dhcpsrv_log.h',
    'dhcpsrv_messages.h',
    'flq_allocation_state.h',
    'flq_allocator.h',
    'fuzz_log.h',
    'fuzz_messages.h',
    'host.h',
    'host_container.h',
    'host_data_source_factory.h',
    'host_mgr.h',
    'hosts_log.h',
    'hosts_messages.h',
    'ip_range.h',
    'ip_range_permutation.h',
    'iterative_allocation_state.h',
    'iterative_allocator.h',
    'key_from_key.h',
    'lease.h',
    'lease_file_loader.h',
    'lease_file_stats.h',
    'lease_mgr.h',
    'lease_mgr_factory.h',
    'legal_log_db_log.h',
    'memfile_lease_limits.h',
    'memfile_lease_mgr.h',
    'memfile_lease_storage.h',
    'ncr_generator.h',
    'network.h',
    'network_state.h',
    'packet_fuzzer.h',
    'parsers/base_network_parser.h',
    'parsers/client_class_def_parser.h',
    'parsers/dhcp_parsers.h',
    'parsers/dhcp_queue_control_parser.h',
    'parsers/duid_config_parser.h',
    'parsers/expiration_config_parser.h',
    'parsers/host_reservation_parser.h',
    'parsers/host_reservations_list_parser.h',
    'parsers/ifaces_config_parser.h',
    'parsers/multi_threading_config_parser.h',
    'parsers/option_data_parser.h',
    'parsers/sanity_checks_parser.h',
    'parsers/shared_network_parser.h',
    'parsers/shared_networks_list_parser.h',
    'parsers/simple_parser4.h',
    'parsers/simple_parser6.h',
    'pool.h',
    'random_allocation_state.h',
    'random_allocator.h',
    'resource_handler.h',
    'sanity_checker.h',
    'shared_network.h',
    'srv_config.h',
    'subnet.h',
    'subnet_id.h',
    'subnet_selector.h',
    'timer_mgr.h',
    'tracking_lease_mgr.h',
    'utils.h',
    'writable_host_data_source.h',
]
install_headers(kea_dhcpsrv_headers, preserve_path: true, subdir: 'kea/dhcpsrv')

if KEA_MSG_COMPILER.found()
    current_source_dir = meson.current_source_dir()
    target_gen_messages = run_target(
        'src-lib-dhcpsrv-alloc_engine_messages',
        command: [
            CD_AND_RUN,
            TOP_SOURCE_DIR,
            KEA_MSG_COMPILER,
            'src/lib/dhcpsrv/alloc_engine_messages.mes',
        ],
    )
    TARGETS_GEN_MESSAGES += [target_gen_messages]
    target_gen_messages = run_target(
        'src-lib-dhcpsrv-dhcpsrv_messages',
        command: [
            CD_AND_RUN,
            TOP_SOURCE_DIR,
            KEA_MSG_COMPILER,
            'src/lib/dhcpsrv/dhcpsrv_messages.mes',
        ],
    )
    TARGETS_GEN_MESSAGES += [target_gen_messages]
    target_gen_messages = run_target(
        'src-lib-dhcpsrv-hosts_messages',
        command: [
            CD_AND_RUN,
            TOP_SOURCE_DIR,
            KEA_MSG_COMPILER,
            'src/lib/dhcpsrv/hosts_messages.mes',
        ],
    )
    TARGETS_GEN_MESSAGES += [target_gen_messages]
    target_gen_messages = run_target(
        'src-lib-dhcpsrv-fuzz_messages',
        command: [
            CD_AND_RUN,
            TOP_SOURCE_DIR,
            KEA_MSG_COMPILER,
            'src/lib/dhcpsrv/fuzz_messages.mes',
        ],
    )
    TARGETS_GEN_MESSAGES += [target_gen_messages]
endif
